package com.library.servlet.student;

import com.library.service.student.BorrowRecordService;
import com.library.servlet.BaseServlet;
import com.library.entity.Student;
import com.library.util.StudentContext;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/student/borrowRecord/*")
public class BorrowRecordServlet extends BaseServlet {
    private BorrowRecordService borrowRecordService = new BorrowRecordService();

    // 查看个人借书记录
    protected void showBorrowRecords(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Student student = StudentContext.getStudent();
        String sno = student.getSno();
        String status = req.getParameter("status");
        req.setAttribute("status", status);
        req.setAttribute("recordList", borrowRecordService.getBorrowRecords(sno, status));
        req.getRequestDispatcher("/WEB-INF/student/showBorrowRecords.jsp").forward(req, resp);
    }
} 